<template>
    <el-breadcrumb>
        <el-breadcrumb-item :to="{ path: 'home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>个人信息</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="info" v-if="personinfo.stuid != null">
        <el-descriptions title="个人信息" border align="center">
            <el-descriptions-item :rowspan="2" :width="140" label="照片" align="center">
                <el-image style="width: 100px; height: 100px"
                    src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
            </el-descriptions-item>
            <el-descriptions-item label="学号" align="center">{{ personinfo.stuid }}</el-descriptions-item>
            <el-descriptions-item label="姓名" align="center">{{ personinfo.name }}</el-descriptions-item>
            <el-descriptions-item label="年级" align="center">{{ personinfo.grade }}</el-descriptions-item>
            <el-descriptions-item label="民族" align="center">{{ personinfo.nationality }}</el-descriptions-item>
            <el-descriptions-item label="班级" align="center">{{ personinfo.class }}</el-descriptions-item>
            <el-descriptions-item label="专业" align="center">{{ personinfo.major_name }}</el-descriptions-item>
            <el-descriptions-item label="辅导员" align="center">{{ personinfo.teacher }}</el-descriptions-item>
            <el-descriptions-item label="入学时间" align="center">{{ personinfo.startdate.slice(0, 10) }}</el-descriptions-item>
            <el-descriptions-item align="center" span="3" label="荣誉">
                <p v-for="(item, i) in honor" :key="i">
                    {{ item.honor }}{{ item.create_time }}
                </p>
            </el-descriptions-item>
            <el-descriptions-item align="center" label="操作">
                <el-button type="primary" size="small" @click="bus.emit('showpwd')">修改密码</el-button>
            </el-descriptions-item>

        </el-descriptions>
    </div>
    <div v-else>
        <el-empty :image-size="200" />
    </div>
    <setpwd title="学号" type="1"></setpwd>
</template>

<script setup lang='ts'>
import { ref, onMounted } from 'vue'
import { getstuinfo } from '@/apis/person';
import bus from '@/utils/mitt';
import setpwd from '@/components/setpwd.vue';
// @ts-ignore
import { Userstore } from '@/stores/user.js';
const userstore = Userstore()
const personinfo = ref<any>({})
const honor = ref<any>([])
const getpersoninfo = async () => {
    const res = await getstuinfo({ stuid: userstore.userinfo.stuid  })
    personinfo.value = res.data.person
    honor.value = res.data.honor
}
onMounted(() => {
    getpersoninfo()
})
</script>
<style lang='scss' scoped></style>